<template>
	<view class="">
		<navbar title="预约会议" :back="true" color="#fff" leftIconColor="#fff"/>
		 <view style="padding-bottom: 40rpx;">
			 <calendar :list='list' @getDate='getDate'></calendar>
		 </view>
		<view style="padding-top:40rpx;border-top: 2rpx solid #eee;">
			<view style="display: flex;justify-content: space-between;align-items: center;padding: 0 20rpx;">
				<view style="font-weight: 650;">当前日期</view>
				<view style="display: flex;align-items: center;" @click="golist()">
					<view style="color: #999999;font-size: 26rpx;margin-right: 10rpx;">全部预约</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
			</view>
			<view style="margin-top: 20rpx;" v-if="yuList.length==0">
				<u-empty
				        text='当前日期暂无会议哦~'
				        mode="list"
				        icon="http://cdn.uviewui.com/uview/empty/list.png"
				>
				</u-empty>
			</view>
			<view style="margin:20rpx 20rpx 0 20rpx;" v-else>
				 <listItem :list="yuList" :params='params' bgcolor="#f6f6f6"></listItem>
			</view>
		</view>
	</view>
</template>

<script>
	import listItem from "@/components/lsitItem.vue"
	import navbar from "@/components/baseNavbar.vue"
	import calendar from "@/components/calendar.vue"
	import {
		getreseDate,
	} from "@/api/make.js"
	import {
		getIndexList
	} from "@/api/make.js"
	export default{
		components:{
			navbar,
			calendar,
			listItem
		},
		data(){
			return{
				list:[],
				yuList:[],
				params: {
					limit: 10,
					page: 1,
					statue:'',
					beginTime:'',
					load: true,
					loadTxt:''
				},
				loading: false,
				loadend: false,
			}
		},
		onLoad(){
			getreseDate().then(res=>{
				console.log('11111',res);
				res.data.forEach(item=>{
					if(item.selfNum!=0){
						let obj={}
						obj.date = item.day
						obj.info = `已报名${item.selfNum}场`
						this.list.push(obj)
					}else{
						let obj={}
						obj.date = item.day
						obj.info = `可预约${item.num}场`
						this.list.push(obj)
					}
				})
			}),
			this.getcurdate()
		},
		methods:{
			getcurdate(){
				let now = new Date();
				let year = now.getFullYear();
				let month = now.getMonth() + 1;
				let date = now.getDate();
				this.params.beginTime = year+'-'+month+'-'+date
				console.log('111',this.params.beginTime);
				this.resetList()
			},
			getDate(e){
				this.params.beginTime = e
				this.resetList()
			},
			resetList() {
				this.params.page = 1
				this.yuList=[]
				this.getList()
			},
			getList() {
				if (!this.params.load) {
					return;
				}
				this.params.load = false;
				this.params.loadTxt = '加载中';
				getIndexList(this.params).then(res => {
					this.params.page++
					this.yuList = this.yuList.concat(res.data.list)
					this.params.load = true
					this.params.loadTxt = '已经到底啦~';
				})
			
			},
			golist(){
				uni.navigateTo({
					url:'/pages/sub/store/screen'
				})
			}
		}
		
	}
</script>

<style>
</style>